<?php
/*----------------------------------------------------------------------------------------*/
/*------------------------- Ce fichier génère le calendrier ICS  -------------------------*/
/*----------------------------------------------------------------------------------------*/
include_once 'icsMaker.php';
include_once 'parseXML.php';

		
if(isset($_POST['str_modules']) && isset($_POST['str_categories']) &&isset($_POST['xml_file'])){	
	$cal_name = str_replace(".xml", ".ics", $_POST['xml_file']);
	
	header('Content-Type: text/Calendar; charset=utf-8');
	header('Content-Disposition: inline; filename='.$cal_name);

	$str_modules = $_POST['str_modules'];
	$str_modules = stripcslashes($str_modules); //On retire les quotes back-slashés par JS
	$tab_modules = explode("|", $str_modules);
		
	$str_categories = $_POST['str_categories'];
	$str_categories = stripslashes($str_categories); 
	$tab_categories = explode("|", $str_categories);	
	

	$xml_file = "http://www.disvu.u-bordeaux1.fr/et/edt_etudiants2/Master/Semestre1/".$_POST['xml_file'];
	$timetable = parseXML($xml_file);

	makeICS($timetable, $tab_categories, $tab_modules, $cal_name);	
}

?>
